package com.yanqu.road.logic.sort;

import com.yanqu.road.entity.rank.cross.CrossUnionActivityRank;

import java.util.Comparator;

public class CrossUnionActivityRankSort implements Comparator<CrossUnionActivityRank> {
    @Override
    public int compare(CrossUnionActivityRank o1, CrossUnionActivityRank o2) {
        if (!o1.isDel() && !o2.isDel()) {
            int result = o2.getValue().compareTo(o1.getValue());
            if (result != 0) {
                return result;
            }
            long time = o1.getLastUpdateTime() - o2.getLastUpdateTime();
            result = time > 0 ? 1 : (time == 0 ? 0 : -1);
            return result;
        }
        if (o1.isDel() && o2.isDel()) {
            return 0;
        }
        if (o1.isDel()) {
            return 1;
        }
        return -1;
    }
}
